<?php get_instance()->view('common/header');?>
<style type="text/css">
	div .radio-inline:nth-child(2), div .checkbox-inline:nth-child(2) {
		margin-left: 10px;
	}
	.box:after{clear:both;conten:"";display:block;}
	.panel{border:0;}
	.panel-title{text-align:left; color:#36b3b3 !important;}
	.panel-title .btn{color:#fff;}
	.panel-body{padding:0;}
	.panel-default>.panel-heading{border:0;}
	.panel-heading{padding-left:9px;}
	.fa-pencil{}
	.table-bordered .dier td{color:#999;}
	.tablewu td{text-align:left;}
	.jine{color:#36b3b3; font-size:16px;}
    .panel-title .btn{
        position: relative;
        top:-2px;
    }
    .tablewu>thead>tr>td{border-bottom-width: 1px;}
    .match-body>li{padding: 5px}
    .match-body>li>span{margin-right: 10px}
    .status-str>span{padding: 0 6px;height: 22px;display: inline-block;line-height: 22px;margin: 0;float: left;
        margin-right: 10px;}
    .status-str>a{height: 22px;line-height: 22px;padding: 0 6px;float: left;}
</style>
<div class="page-container">
	<!-- BEGIN SIDEBAR -->
    <?php get_instance()->view('common/sidebar');?>
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<!-- BEGIN PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					<h3 class="page-title"> <?php echo $title?> </h3>
					<ul class="page-breadcrumb breadcrumb">
						<li class="btn-group"><a  href="<?php echo $backUrl?>" class="btn default"><i class="fa fa-chevron-left"></i> 返回</a> </li>
						<li> <a href="javascript:void(0);"> 商品管理 </a> <i class="fa fa-angle-right"></i> </li>
						<li> <a href="<?php echo $backUrl?>"> 订单列表 </a> <i class="fa fa-angle-right"></i></li>
						<li> <?php echo $title?></li>
					</ul>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <!--新订单列表 基本信息-->
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title text-center">基本信息</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered">
                                    <tbody>
                                        <tr>
                                            <td>ID</td>
                                            <td>订单号</td>
                                            <td>商家</td>
                                            <td>会员</td>
                                            <td>电话</td>
                                            <td>应付</td>
                                            <td>订单状态</td>
                                            <td>下单时间</td>
                                            <td>支付时间</td>
                                            <td>支付方式</td>
                                        </tr>
                                        <tr class="dier">
                                            <td><?php echo $info['id']?></td>
                                            <td><?php echo $info['code']?></td>
                                            <td><?php echo $info['merchant']?></td>
                                            <td><?php echo $info['consumer']?></td>
                                            <td><?php echo $info['consumer_mobile']?></td>
                                            <td><?php echo $info['reality_amount']?></td>
                                            <td class="status-str"><?php echo $info['status_format_str']?>
                                                <?php if ($info['expense_type'] == 1 && $info['status'] > 2 && $info['status'] < 6):?>
                                                <a href="#" class="btn green btn-xs logistics"><i class="fa fa-eye"></i>
                                                查看物流</a>
                                                <?php endif;?>
                                            </td>
                                            <td><?php echo $info['addtime']?></td>
                                            <td><?php echo $info['pay_time']?></td>
                                            <td><?php echo $info['pay_type_str']?></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <!--收货人信息-->
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title text-center">
                                    <a class="btn btn-primary btn-xs address-edit" data-original-title="编辑收货地址" title="" data-toggle="tooltip" href="javascript:;">
                                        <i class="fa fa-pencil"></i>
                                    </a>
                                    收货信息
                                </h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered tablewu">
                                    <tbody>
                                        <tr>
                                            <td>收货人</td>
                                            <td>联系方式</td>
                                            <td>区域</td>
                                            <td>详细地址</td>
                                            <td>配送方式</td>
                                        </tr>
                                        <tr class="dier address-list">
                                            <td><?php echo $info['contacts']?></td>
                                            <td><?php echo $info['mobile']?></td>
                                            <td><?php echo $info['province'].' - '.$info['city'].' - '.$info['county']?></td>
                                            <td><?php echo $info['address']?></td>
                                            <td><?php echo $info['expense_type_str']?></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <!--商品信息-->
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title text-center">
                                    商品信息
                                </h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered tablewu">
                                    <thead>
                                    <tr>
                                        <td class="text-left">商品</td>
                                        <td class="text-left">规格</td>
                                        <td class="text-right">数量</td>
                                        <td class="text-right">单品价格</td>
                                        <td class="text-right">单品小计</td>
                                        <td class="text-right">申请售后</td>
                                        <?php $colSpan = 6; if (isset($buttons['product'])): $colSpan = 7;?>
                                            <td class="text-right product-btn" width="10px">操作</td>
                                        <?php endif;?>
                                    </tr>
                                    </thead>
                                    <tbody>
                                        <?php $product = false;  foreach ($oP as $k=>$v):?>
                                            <tr class="dier">
                                                <td class="text-left"><?php echo $v['name']?></td>
                                                <td class="text-left"><?php echo $v['property']?></td>
                                                <td class="text-right"><?php echo $v['quantity']?></td>
                                                <td class="text-right">￥<?php echo $v['price']?></td>
                                                <td class="text-right">￥<?php echo round($v['price']*$v['quantity'], 2)?></td>
                                                <td class="text-right"><?php echo $v['after_sale'] == 2 ? '已申请' : '未申请';?></td>
                                                <td class="text-right product-btn" data-id="<?php echo $v['id']?>">
                                                    <?php if (isset($buttons['product']) && $v['after_sale'] == 1): $product = true; ?>
                                                        <?php echo $buttons['product']?>
                                                    <?php endif;?>
                                                </td>
                                            </tr>
                                        <?php endforeach;?>
                                        <?php if ($product === false): $colSpan = 6;?>
                                            <script type="text/javascript">
                                                $(".product-btn").remove();
                                            </script>
                                        <?php endif;?>
                                    <tr>
                                        <td colspan="<?php echo $colSpan;?>" class="text-right">商品合计:<label class="jine">￥<?php echo $info['product_amount']?></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="<?php echo $colSpan;?>" class="text-right">备注:<label class="jine"><?php echo $info['remark']?></label></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                         <!--新订单列表 费用信息-->
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title text-center">费用信息</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered">
                                    <tbody>
                                    <tr>
                                        <td colspan="5" class="text-right">商品总金额：￥<?php echo $info['product_amount']?><?php if (isset($info['shipping_fee'])) echo '+配送费:￥'.$info['shipping_fee'];?></td>
                                    </tr>
                                    <tr>
                                        <td class="text-right">= 订单总金额：<label class="jine">￥<?php echo $info['total_amount']?></label></td>
                                    </tr>
                                    <?php if (!empty($info['param'])):?>
                                        <tr>
                                            <td class="text-right">
                                                <?php foreach ($info['param'] as $k => $v):
                                                if ($k == 'red_packet'){ echo "-红包：￥".$v;}
                                                if ($k == 'voucher'){ echo "-代金券：￥".$v;}
                                                if ($k == 'first_order_reduce'){ echo "-商家首单减免：￥".$v;}
                                                if ($k == 'full_cut'){ echo "-满减：￥".$v;}
                                                 endforeach;?>
                                            </td>
                                        </tr>
                                    <?php endif;?>
                                    <tr>
                                        <td class="text-right">= 应付款金额：<label class="jine">￥<?php echo $info['reality_amount']?></label></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <!--新订单列表 操作信息-->
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title text-center">操作信息</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered">
                                    <tbody>
                                    <tr>
                                        <div class="row">
                                            <td colspan="4">
                                                <form id="">
                                                    <textarea id="order_action" placeholder="请输入操作备注" rows="3" class="form-control" style="border:0;"></textarea>
                                                </form>
                                            </td>
                                        </div>
                                    </tr>
                                    <tr>
                                        <div class="row">
                                            <td class="text-left col-sm-2"><p class="margin" style="margin:0;line-height:34px;">当前可执行操作：</p></td>
                                            <td colspan="3">
                                                <div class="input-group buttons">
                                                    <?php echo isset($buttons['order']) ? $buttons['order'] : ''?>
                                                </div>
                                            </td>
                                        </div>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <!--新订单列表 操作记录信息-->
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title text-center">操作记录</h3>
                            </div>
                            <div class="panel-body">
                                <div class="portlet">
                                    <div class="portlet-body">
                                        <div class="table-container">
                                            <div class="table-actions-wrapper"> <span> </span></div>
                                            <table class="table table-bordered table-hover" id="data-table">
                                                <thead>
                                                    <tr role="row" class="heading">
                                                        <th> 操作者</th>
                                                        <th> 操作时间</th>
                                                        <th> 订单状态</th>
                                                        <th> 备注 </th>
                                                    </tr>
                                                </thead>
                                                <tbody></tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
		</div>
	</div>
	<!-- END CONTENT -->
</div>
<!-- END CONTENT -->
<?php get_instance()->view('order/address_from.php'); // 编辑收货人信息?>
<?php get_instance()->view('order/delivery_from.php'); // 发货?>
<?php get_instance()->view('order/logistics_from.php'); // 查看物流信息?>
<?php get_instance()->view('order/service_from.php'); // 申请售后?>

</body>
</html>
<script>
    $(function () {
       $(".ajax-order-btn").live('click',function () {
           var url = $(this).attr('href');
           var message = $(this).attr('alert-message');
           var id = '<?php echo $info['id']?>';
           var note = $("#order_action").val();
           confirmMessage({
               url:url,
               info:message,
               confirmCallback:function(option){
                   App.blockUI({message:'保存中...'});
                   $.ajax(option.url, {
                       dataType:'json',
                       type:'post',
                       data:{id:id,note:note},
                       error:function(){
                           show_message({status:0, message:'请求超时'});
                           App.unblockUI();
                       },
                       timeout:60000,
                       success:function(data,textStatus,jqXHR){
                           show_message(data);
                           if (data.status == 1){
                               if (data.url){
                                   window.setTimeout("window.location.href = data.url", 1000);
                               }else{
                                   $(".status-str").html(data.data.status_format_str);
                                   $("#order_action").val('');
                                   $(".buttons").html(data.data.buttons);
                                   $("#data-table").dataTable().fnDraw(true);
                               }
                           }
                           App.unblockUI();
                       }
                   });
               }
           });
           return false;
       });
    });
    
    $(function(){
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#data-table"),
            sAjaxSource: "<?php echo getUrl('order/home/getOrderLogList?order_id='.$info['id']);?>",
            bSort:false
        });
    })
</script>